<?
function show_chapters($chapters){
    echo "<ul id=\"menu\">";
    $current_href = Request::$initial->uri();

    foreach($chapters as $chapter){
        $class = (str_replace('/', '', $chapter['href']) == str_replace('/', '', $current_href)) ? "class=\"current\"": '';
        echo "<li><a $class href=\"{$chapter['href']}\">{$chapter['name']}</a>";
        if(isset($chapter['subchapters']))
            echo show_chapters($chapter['subchapters']);    
        echo "</li>";
    }
    echo "</ul>";
}

show_chapters($chapters); 

?>